#!/bin/sh
# Source: http://www.ubuntu.org.tw/modules/newbb/viewtopic.php?topic_id=6067

echo '正在下載 Adobe Reader 8.1.2 Linux 版...'
mkdir -p temp/adobe-reader
TOP_DIR=`pwd`

cd temp/adobe-reader

$WGET 'http://ardownload.adobe.com/pub/adobe/reader/unix/8.x/8.1.2/cht/AdobeReader_cht-8.1.2-1.i386.deb'
$WGET 'http://ardownload.adobe.com/pub/adobe/reader/unix/8.x/8.1.2/misc/FontPack81_cht_i486-linux.tar.gz'

# Remove English version if it's installed
sudo apt-get --force-yes -y --purge remove adobereader-enu
# Remove old config file, or Chinese interface cannot be used.
rm -f "$REAL_HOME/.adobe/Acrobat/8.0/Preferences/reader_prefs"

echo '正在安裝 Adobe Reader 8.1.2...中文版'
"$TOP_DIR/scripts/debinstall.py" *.deb

echo '正在安裝 Adobe Reader 繁體中文字型支援...'
tar -xzf FontPack81_cht_i486-linux.tar.gz
cd CHTKIT

# We don't call INSTALL provided by Adobe here.
# Simply extracting the *.tar files is enough.
FILES=`dir *.TAR`
for file in $FILES
do
    tar --directory=/opt --no-same-owner -xpf "$file"
done

#解決libgtkembedmoz問題
sudo -u "$REAL_USER" mkdir -p "$REAL_HOME/.adobe/Acrobat/8.0/Preferences/"
sudo -u "$REAL_USER" cat > "$REAL_HOME/.adobe/Acrobat/8.0/Preferences/acrogre.conf" << EOF
/usr/lib/firefox/
EOF

su -c "mkdir -p $REAL_HOME/.local/share/applications" "$REAL_USER"
su -c "xdg-mime default AdobeReader.desktop application/pdf" "$REAL_USER"

cd "$TOP_DIR"
